define(['jq','common'],()=>{
    setTimeout(()=>{
        // 吸顶
        $(window).scroll(function () {
            if ($(window).scrollTop() > 36) {
                $('.navBottom').css({
                    'position': 'fixed',
                    'top': '0'
                })
            } else if ($(window).scrollTop() <= 36) {
                $('.navBottom').css({
                    'position': 'absolute',
                    'top': '36px'
                })
            }
        })

        $('.name').on('click',function(){
            location.href = '../html/self_info.html'
        })
        // 登录
        let name = document.querySelector('.name')
        let out = document.querySelector('.out')
        let login = document.querySelector('.login')
        let user = getCookie('username')
        let em = document.querySelector('em')
        if (user) {
            name.style.display = 'block'
            name.innerHTML = `欢迎：${user}`
            out.style.display = 'block'
            login.style.display = 'none'
            em.style.display = 'block'
        } else {
            name.style.display = 'none'
            out.style.display = 'none'
            login.style.display = 'block'
            em.style.display = 'none'
        }
        out.onclick = function () {
            name.style.display = 'none'
            out.style.display = 'none'
            login.style.display = 'block'
            em.style.display = 'none'
            delCookie('username')
        }

        // 下拉菜单
        class Xiala {
            constructor() {
                this.caidan = document.querySelectorAll('.caidan')
                this.nav = document.querySelector('.nav')
                this.catalog = document.querySelectorAll('.catalog')
                this.init()
            }
            init() {
                this.add()
            }
            add() {
                this.nav.addEventListener('mouseover', (e) => {
                    var e = e || window.event
                    var target = e.target || target.srcElement
                    if (target.className == 'caidan') {
                        target.children[0].children[0].style.display = 'none'
                        target.children[0].children[1].style.display = 'block'
                        target.children[1].style.display = 'block'
                    }
                })
                this.nav.addEventListener('mouseout', (e) => {
                    var e = e || window.event
                    var target = e.target || target.srcElement
                    if (target.className == 'catalog') {
                        target.parentNode.children[0].children[0].style.display = 'block'
                        target.parentNode.children[0].children[1].style.display = 'none'
                        target.style.display = 'none'
                    }
                })
            }
        }
        new Xiala()

    },500)
})